
\chapter{Introduction}


{\bf T} is a dialect of Lisp derived from Scheme
\cite{rrs}.
It is comparable in power and expressivness to other recent Lisp
dialects such as Lisp Machine Lisp
\cite{Weinreb81}, Common Lisp \cite{CLtL}, and NIL \cite{White79},
but fundamentally more similar in spirit to Scheme than these other
Lisp dialects.

{\bf T} is an attempt to create a powerful and expressive language which
is portable, efficient, and suitable for a broad variety of applications,
including symbolic, numerical, and systems programming.

{\bf T} draws from many sources in its attempt to provide a complete
yet simple and unified system.
For the most part, the language's designers are collators, not
originators.
Common Lisp, NIL, and Scheme have been the strongest influences.

\section{Notation}

Throughout this document the following conventions are used:
\begin{description}
\item[{\{ \ldots\  \}}]
Curly braces group together whatever they enclose.

\item[{[ \ldots\  ]}]
Square brackets indicate that what they enclose is optional.
See also {\it Dot-notation\/} below.

\item[{$^*$\ }]
Braces or brackets followed by a star,
{\mbox {e.g. \{ \ldots\  \}$^*$\ }},
indicate zero or more occurences of the enclosed item.
See also {\it Dot-notation\/} below.

\item[{$^+$}]
Braces or brackets followed by a plus sign, e.g.
[ \ldots\  ]$^+$, indicate one or more occurences of the enclosed
item.

\item[{$|$}]
A vertical bar is used to separate alternatives in a
braced or bracketed group, e.g. \{ thing1 $|$ \ldots\  $|$ thingN \}.

\item[{$\Longrightarrow$\ }]
is used to indicate {\it evaluation\/}.
(Evaluation is described in section \ref{section:coreLanguage}.)
It is read as ``evaluates to''.
For example, {\mbox {{\tt (+ 3 5) $\Longrightarrow$\  8}}} means that evaluating the
expression {\mbox {{\tt (+ 3 5)}}} yields {\mbox {{\tt 8}}}.

\item[{$\equiv$}]
indicates {\it code equivalence\/}.
It is read as ``is equivalent to''.
For example, {\mbox {{\tt (CAR (CDR {\it x\/})) $\equiv$ (CADR {\it x\/})}}}
means that for any {\it x\/},
the value and effects of {\mbox {{\tt (CAR (CDR {\it x\/}))}}} are always the
same as the value and effects of {\mbox {{\tt (CADR {\it x\/})}}}.

\item[{$\longrightarrow$\ }]
is used in definitions to indicate
the {\it type\/} of the result.  For example,
{\mbox {{\tt (NUMBER? {\it object\/}) $\longrightarrow$\  {\it boolean\/}}}}
means that the procedure named {\mbox {{\tt NUMBER?}}} yields a boolean result.
\begin{codexenv}
(PRINT {\it object port\/}) $\longrightarrow$\  {\it undefined}
\end{codexenv}
means that {\mbox {{\tt PRINT}}}
returns a value of no particular interest; that is, one should
not depend on it to return anything in particular.

\item[{{\it Italicized\/}}]
names in the code examples are meta-variables
that stand
for pieces of code to be filled in.  Restrictions on the particular
types or values of a meta-variable are often suggested by its name or
are given in the text associated with the example.
The term {\it object\/} denotes data of unrestricted type.

\item[{{\it Dot-notation\/}}], as in {\mbox {{\tt (ADD . {\it numbers\/})}}},
is used where any
number of sub-forms are permitted.  In this example, there may be zero
or more {\it numbers\/};
the description subsumes cases such as {\mbox {{\tt (ADD)}}},
{\mbox {{\tt (ADD 3)}}}, and {\mbox {{\tt (ADD 3 5 2)}}}.
See also $^*$\  and ([ \ldots\  ]) above.

\item[{{\it Settable\/}}]
Some routines described in this manual, such as {\mbox {{\tt VREF}}}
(page \pageref{VREF}), serve as {\it access routines\/} in
the sense that they are appropriate for use in {\mbox {{\tt SET}}} and related
forms to designate locations.  These routines have their descriptions
flagged with the notation {\it Settable\/}.

\item[{{\it Type Predicate\/}}]
Functions that take an object of any type as an argument and return
a boolean are called type predicates. They return true if the
argument was of the required type and false otherwise.

\item[{{\it Operation\/}}]
Functions that dispatch on their first argument are labelled as
{\it operations\/}. See Chapter \ref{chapter:operations}.
\end{description}

\section{Naming Conventions}

Below are listed some of the naming conventions used for standard {\bf T}
procedures, variables, and reserved words.
\begin{description}
\item[{{\tt \ldots\ ?}}]
The suffix {\tt ?} indicates a predicate.  For example,
{\tt ZERO?} is a predicate which returns true if its argument is
numerically equal to zero.

\item[{{\tt \ldots\ !}}]
The suffix {\tt !} indicates a side-effecting variant of a
non-side-effecting procedure.  For example, {\tt REVERSE!} is the same as
{\tt REVERSE}, but it alters its argument, recycling the storage to
form its result.

\item[{{\tt \ldots\ -$>$\ldots\ }}]
Infix {\tt -$>$} is used in names of {\it coercion procedures\/},
which are routines which perform conversions
between objects of different types.  For example, given a string,
{\tt STRING-$>$LIST} forms a list of the characters in the string.

\item[{{\tt *\ldots\ *}}]
The names of mutable variables whose scope is not
visually apparent
to someone reading the program is usually bounded on either side with
{\tt *}'s.  

\item[{{\tt DEFINE-\ldots\ }}]
Relates to the assignment of something in a permanent
way.  {\tt DEFINE} is typically used for defining procedures,
{\tt DEFINE-OPERATION} to define generic operations, and so forth.

\item[{{\tt MAKE-\ldots\ }}]
Indicates a routine which creates an object of some type,
given size (and sometimes datatype) information.  For example,
{\tt (MAKE-STRING 5)} makes a string of length 5.

\item[{{\tt NOT-\ldots\ }}]
The prefix ``{\tt NOT-}'' means that the truth value of some
predicate is complemented.  For example, {\mbox {\tt (NOT-LESS? {\it x\/} {\it y\/})}}
is the same as {\mbox {\tt (NOT (LESS? {\it x\/} {\it y\/}))}}.

\item[{{\tt \ldots\ CDR}}]
Relates to the subtail or successive subtails of a list.
For example, while the procedure named {\tt NTH} returns the nth
{\it element\/} of a list, there is another procedure named {\tt NTHCDR} that
returns the nth {\it subtail\/}.

\item[{{\tt \ldots\ Q}}]
The presence of the trailing character ``{\tt Q}'' on a name
typically means that the predicate ``{\tt EQ?}'' is involved.  For
example,
\begin{codexenv}
(MEMQ? {\it x\/} {\it l\/})  $\equiv$  (MEM? EQ? {\it x\/} {\it l\/})
\end{codexenv}
\end{description}

\section{Language principles and conventions}

The design of {\bf T} employs a number of conventions.
These conventions make the language more regular, predictable, and
easy to learn.

{\it Anonymity:\/} objects are not tightly coupled to their names.

{\it Locality:\/} effects may be achieved locally.

{\it Argument order:\/} procedures which extract components from aggregate
objects generally take the aggregate object as the first argument, and
selection information (if any) as subsequent arguments.
Similarly, assignment procedures take the aggregate object or location
specification early, and the value to be stored last.

{\it Indexing:\/} where numeric indices are involved, the indices begin with
zero and range up to a given limit.  Ranges are specified as
{\it half-open intervals\/}, inclusive at the low end and exclusive at the
high end.

{\it Abbreviations:\/} are avoided
in names of {\bf T} entities.  Words are spelled out and separated by
hyphens, e.g. {\tt DEFINE-OPERATION}, {\tt STRING-LENGTH}.
Where abbreviations are used, they are used consistently:
e.g. {\tt CHAR} abbreviates {\tt CHARACTER}, as in {\tt CHAR?},
and {\tt ELT} abbreviates {\tt ELEMENT}, as in {\tt STRING-ELT}.



